package cn.itheima.service.dept.impl;

import cn.itheima.dao.dept.DeptDao;
import cn.itheima.domain.Dept;
import cn.itheima.service.dept.DeptService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptDao deptDao;

    //分页全查
    public PageInfo findAll(int pageNum, int pageSize,String company_id) {
        PageHelper.startPage(pageNum,pageSize);
        List<Dept> list = deptDao.findAll(company_id);
        PageInfo pb = new PageInfo(list);
        return pb;
    }

    //公司部门
    public List<Dept> toAdd(String company_id) {
        List<Dept> list = deptDao.findAll(company_id);
        return list;
    }

   //添加部门
    public void edit(Dept dept) {
        deptDao.edit(dept) ;
    }

    //删除部门
    public void delete(String id) {
        deptDao.delete(id);
    }

    //修改的回显
    public Dept findById(String id) {
        Dept dept = deptDao.findById(id);
        return dept;
    }

    //修改部门信息
    public void update(Dept dept) {
        deptDao.update(dept);
    }


}
